package backend.service.charisma;

import backend.model.base.DBModel;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository(value = "CharismaDao")
public class CharismaDaoImpl<DBM extends DBModel> extends HibernateDaoSupport implements CharismaDao<DBM> {

	@Autowired
	public CharismaDaoImpl(@Qualifier("charismaSessionFactory") SessionFactory sessionFactory) {
        setSessionFactory(sessionFactory);
	}

    @Override
    public List<DBM> findByNamedQuery(String queryName) {
        return getHibernateTemplate().findByNamedQuery(queryName);
    }

    @Override
    public List<DBM> findByNamedQueryAndParams(String queryName, String[] paramNames, Object[] paramValues) {
        return getHibernateTemplate().findByNamedQueryAndNamedParam(queryName, paramNames, paramValues);
    }
}